<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">停止</button>
    <script>
        /* 
            setInterval(function(){
    
            },毫秒值) //表示每过一段多长的毫秒值就执行定时器里面的代码
        */

        var timer = setInterval(function(){
            console.log("这个是一个永久性定时器");
        },1000)


        btn.onclick = function(){
            //停止setInterval这个定时器
            clearInterval(timer)
        }
    </script>
</body>
</html>